using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;

namespace MingProject
{
    public class WBS
    {
        public WBS(string WBSStr)
        {
            _WBSString = WBSStr;
            
            WBSArray = WBSStr.Split('.');
        }
        public int Level
        {
            get
            {
                return (WBSArray.Length);
            }
        }


        public string _WBSString;
        public string WBSString
        {
            get { return _WBSString; }
            set
            {
                _WBSString = value;
                WBSArray = value.Split('.');
            }

        }
        public StringCollection _WBSCollection;
        public string[] WBSArray
        {
            get
            { 
                string[] s=new string[_WBSCollection.Count];
                _WBSCollection.CopyTo(s, 0);

                return s;
            }
            set
            {
                _WBSCollection = new StringCollection();
                _WBSCollection.AddRange(value);

                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < _WBSCollection.Count; j++)
                {
                    sb.Append(_WBSCollection[j]);
                    if (j != _WBSCollection.Count - 1)
                    {
                        sb.Append('.');
                    }

                }
                _WBSString = sb.ToString();

            }
        }
             //1.1.1.1+1
        public string Add(int level, int AddValue)
        {
            int i = int.Parse((_WBSCollection[level]));
            i += AddValue;
            _WBSCollection[level] = i.ToString();
            //_WBSString = new StringBuilder(
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < _WBSCollection.Count;j++ )
            {
                sb.Append(_WBSCollection[j]);
                if (j != _WBSCollection.Count - 1)
                {
                    sb.Append('.');
                }

            }
            _WBSString = sb.ToString();
            return _WBSString;
        }
        public string Add(int AddValue)
        {
            int i = _WBSCollection.Count - 1;
            return (Add(i, AddValue));
            

        }
        public string Add()
        {
            return(Add(1));
        }

        

    }
}
